/**
 * 
 */
package uk.ac.manchester.cs.graph.alg;

import uk.ac.manchester.cs.graph.Graph;

/**
 * Breadth-first search
 * 
 * @author Pavel Klinov
 *
 * pklinov@cs.man.ac.uk, pklinov@clarkparsia.com
 * 
 * Mar 6, 2011
 */
public class DFS implements GraphSearchAlgorithm {

	
	public <V,E> void search(Graph<V,E> graph, V start, VertexVisitor<V> visitor) {
		
		if (visitor.visit(start)) {

			for (V next : graph.getAdjacentVertices(start)) {

				search(graph, next, visitor);
			}
		}
	}
}
